package com.cci.kangdao.controller.vip;

import com.cci.kangdao.dto.BaseResponse;
import com.cci.kangdao.service.UserVIPService;
import com.cci.kangdao.utilTool.ParameterTool;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @description: 用户vip 功能模块
 * @author: joe
 * @company: CTY
 * @since: 2024/3/1 13:51
 * @version: V1.0
 **/
@RestController
public class UserVIPController {

    private static Logger log = Logger.getLogger(UserVIPController.class);
    @Autowired
    private UserVIPService userVIPService;

    /**
     * 终端用户获取功能项
     * @param request
     * @param response
     */
    @RequestMapping("userVip/index.aspx")
    public void userVipIndex(HttpServletRequest request, HttpServletResponse response){
        try {
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            userVIPService.userVipIndex(map);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            ParameterTool.writeErrorResponse(response);
        }
    }

    /**
     * 获取我的vip 车队，设备，数量
     */
    @RequestMapping("/getVipData.aspx")
    @ResponseBody
    public void getVipData(HttpServletRequest request, HttpServletResponse response) {
        try {
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            userVIPService.getVipData(map);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            ParameterTool.writeErrorResponse(response);
        }
    }

    /**
     * 保存自定义功能项
     */
    @RequestMapping(value = "/saveAppFunctionCategory.aspx")
    @ResponseBody
    public BaseResponse saveAppFunctionCategory(String paramStr) {
       return userVIPService.saveAppFunctionCategory(paramStr);
    }

    /**
     * 吸引VIP区 集合
     */
    @RequestMapping(value = "/getVipAttract.aspx")
    @ResponseBody
    public BaseResponse getVipAttract() {
        return userVIPService.getVipAttract();
    }


    /**
     * b端用户获取车联网功能项
     * @param request
     * @param response
     */
    @RequestMapping("network/userNetworkVipIndex.aspx")
    public void userNetworkVipIndex(HttpServletRequest request, HttpServletResponse response){
        try {
            Map<String, Object> map = ParameterTool.getParameterRequest(request, true);
            map.put("response", response);
            userVIPService.userNetworkVipIndex(map);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            ParameterTool.writeErrorResponse(response);
        }
    }
}
